<?php
class Admin_Model_DbTable_LibraryVideo extends Zend_Db_Table_Abstract {
	protected $_name = 'lib_video';
	public function addLibVideo($lib_name, $dateon, $dateoff, $description, $status) {
		$data = array (
				'LIB_NAME' => $lib_name,
				'DATEON' => $dateon,
				'DESCRIPTION' => $description,
				'DATEOFF' => $dateoff,
				'STATUS' => $status 
		);
		return $this->insert ( $data );
	}
	public function updateLibVideo($id, $lib_name, $dateon, $dateoff, $description, $status) {
		$data = array (
				'LIB_NAME' => $lib_name,
				'DATEON' => $dateon,
				'DESCRIPTION' => $description,
				'DATEOFF' => $dateoff,
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $id" );
	}
	public function removeLibVideo($id) {
		return $this->delete ( "ID = $id" );
	}
	public function updateStatus($id, $status) {
		$data = array (
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $id" );
	}
	public function getAllLibVideo() {
		return $this->fetchAll("STATUS = 1","ID DESC")->toArray();
	}
	public function getLibVideoByName($lib_name, $status) {
		return $this->fetchAll("LIB_NAME = $lib_name AND STATUS = $status")->toArray();
	}
	public function getLibVideoByLibId($lib_id) {
		return $this->fetchRow("ID = $lib_id")->toArray();
	}
	public function getLibVideoByStatus($status) {
		return $this->fetchAll("STATUS = $status","ID DESC")->toArray();
	}
	public function active($id){
		$lv = $this->fetchRow("ID = $id");
		if($lv->STATUS == 1){
			$this->update(array("STATUS"=>0), "ID = $id");
		}else{
			$this->update(array("STATUS"=>1), "ID = $id");
		}
	}
}

